/**
 * creation: 17-apr-2008
 */
package org.jfonia.structure;

import java.util.List;

import org.jfonia.connect.BasicNode;
import org.jfonia.connect.Callable;
import org.jfonia.connect.ListElement;
import org.jfonia.connect.Node;
import org.jfonia.connect.Value;

/**
 * Slice in IndexFamily.
 * 
 * @author wijnand.schepens@gmail.com
 *
 */
public class IndexSlice extends BasicNode implements Slice
{
	private IndexedFamily family;
	private IntIterator   indexIterator;
	
	private Node           proceeder;
	private Value<Boolean> proceedCondition;
//	private Value<Integer> value;
//	private Value<Integer> lookaheadValue;
	
	public IndexSlice(IndexedFamily fam, IntIterator indexIterator) 
	{
		this.family = fam;
		this.indexIterator = indexIterator;
		
		this.proceeder = indexIterator.getProceeder();
		this.proceedCondition = indexIterator.getProceedCondition();
	}

//	public IndexSlice(IndexedFamily fam, IntIterator indexIterator, List<Integer> keyList) 
//	{
//		this.family = fam;
//		this.indexIterator = indexIterator;
//		
//		this.proceeder = indexIterator.getProceeder();
//		this.proceedCondition = indexIterator.getProceedCondition();
//		this.value = new ListElement<Integer>(keyList, indexIterator.getValue());
//		this.lookaheadValue = new ListElement<Integer>(keyList, indexIterator.getLookaheadValue());
//	}

//	public Value<Integer> getValue()
//	{
//		return value;
//	}
//
//	public Value<Integer> getLookaheadValue()
//	{
//		return lookaheadValue;
//	}
//
	
	
	public Node getProceeder()
	{
		return proceeder;
	}

	public Value<Boolean> getProceedCondition()
	{
		return proceedCondition;
	}

	public Value getProperty(String id)
	{
		return family.getProperty(id, indexIterator.getValue());
	}

	public Value getLookaheadProperty(String id)
	{
		return family.getProperty(id, indexIterator.getLookaheadValue());
	}

	public boolean hasProperty(String id)
	{
		return family.hasProperty(id);
	}

	public Node getFastForwarder(String id, Value target) {
		return family.getFastForwarder(id, target, indexIterator);
	}

	
	public Value<Integer> getKey(String id) {
		return family.getKey(id, indexIterator.getValue());
	}

	public Value<Integer> getLookaheadKey(String id) {
		return family.getKey(id, indexIterator.getLookaheadValue());
	}

	
	
	
	@Override
	public void addCallTarget(Callable callable) {
		indexIterator.getValue().addCallTarget(callable);
	}

	@Override
	public boolean callTargets(Object param) {
		return indexIterator.getValue().callTargets(param);
	}

	@Override
	public void clearCallTargets() {
		indexIterator.getValue().clearCallTargets();
	}

	@Override
	public void removeCallTarget(Callable callable) {
		indexIterator.getValue().removeCallTarget(callable);
	}


//	public IntIterator getIndexIterator()
//	{
//		return this.indexIterator;
//	}

}
